# -*- encoding:utf8 -*-

import MySQLdb
import re

# 打开数据库连接
db = MySQLdb.connect("localhost","root","zsx123456","python_db",charset='utf8')

# 使用cursor()方法获取操作游标
cursor = db.cursor()

file = open("employee.sql","r+")
sql = file.read()
print type(sql)
print "待执行的sql\n",sql
cursor.execute("DROP TABLE IF EXISTS EMPLOYEE")
print "执行返回的结果:",cursor.execute(sql)

version = '''
SELECT VERSION()
'''
cursor.execute(version)

# 使用 fetchone() 方法获取一条数据
data = cursor.fetchone()

print "Database version is %s" % data

# 关闭数据库连接
db.close()




